<?php 

session_start();



if(!isset($_SESSION['username']))

{

	header("Location: ../login.php");

	exit();

} 



?>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Edit Listing</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link rel="stylesheet" type="text/css" href="style.css">

<link rel="stylesheet" type="text/css" href="listing_panel_css.css">



<script language="javascript" type="text/javascript">

function get_checks(feature_array, Name)

{

	if(document.getElementById(feature_array).name = Name)

	{

		alert('adasdsa')

	}

}



function get_mapping()

{

var num = document.getElementById('street_number').value

var dir = document.getElementById('dir').value

var street = document.getElementById('street_name').value

var suffix = document.getElementById('suffix').value

var city = document.getElementById('city').value

var state = document.getElementById('state').value

var zip = document.getElementById('zip').value



window.open('check_mapping.php?num='+num+'&dir='+dir+'&street='+street+'&suffix='+suffix+'&city='+city+'&state='+state+'&zip='+zip, 'mapping', 'Location=no, width=500, height=500')



}



</script>



</head>



<?

$active = 'mylistings';

$edit = 'details';



require_once 'XML/Parser.php';

require ('common/functions.php');

require("../rss/geo.class.php");



function convertDoc2HTML($txt){

        $len = strlen($txt);

        $res = "";

        for($i = 0; $i < $len; ++$i) {

            $ord = ord($txt{$i});

			

			//echo $txt{$i}; echo $ord; echo "<br>";

			

            // check only non-standard chars         

            if($ord >= 126){

                $res .= "&#".$ord.";";

            }

            else {

                // escape ", ' and \ chars

                switch($ord){

                    case 34 :

                        $res .= "\\\"";

                        break;

                    case 39 :

                        $res .= "\'";

                        break;

                    case 92 :

                        $res .= "\\\\";

                        break;                   

                    default : // the rest does not have to be modified

                        $res .= $txt{$i};

                }                   

            }

        }

        return $res;

}



function get_html_translation_table_extended() {

    $trans_ext = get_html_translation_table(HTML_ENTITIES);



	//$trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);





	//echo "before extra chars"; echo "<br>"; print_r($trans); echo "<br>";

	//echo "special chars"; echo "<br>"; echo chr(149); echo '&bull;'; echo "<br>";

	

	  $num = count ($trans_ext);

	  

	  for($count=$num; $count < 160; $count++)

	  {

	  $trans_ext[chr($count)] = '&tilde;';

	  }



		

    $trans_ext[chr(130)] = '&sbquo;';    // Single Low-9 Quotation Mark

    $trans_ext[chr(131)] = '&fnof;';    // Latin Small Letter F With Hook

    $trans_ext[chr(132)] = '&bdquo;';    // Double Low-9 Quotation Mark

    $trans_ext[chr(133)] = '&hellip;';    // Horizontal Ellipsis

    $trans_ext[chr(134)] = '&dagger;';    // Dagger

    $trans_ext[chr(135)] = '&Dagger;';    // Double Dagger

    $trans_ext[chr(136)] = '&circ;';    // Modifier Letter Circumflex Accent

    $trans_ext[chr(137)] = '&permil;';    // Per Mille Sign

    $trans_ext[chr(138)] = '&Scaron;';    // Latin Capital Letter S With Caron

    $trans_ext[chr(139)] = '&lsaquo;';    // Single Left-Pointing Angle Quotation Mark

    $trans_ext[chr(140)] = '&OElig;    ';    // Latin Capital Ligature OE

    $trans_ext[chr(145)] = '&lsquo;';    // Left Single Quotation Mark

    $trans_ext[chr(146)] = '&rsquo;';    // Right Single Quotation Mark

    $trans_ext[chr(147)] = '&ldquo;';    // Left Double Quotation Mark

    $trans_ext[chr(148)] = '&rdquo;';    // Right Double Quotation Mark

    $trans_ext[chr(149)] = '&bull;';    // Bullet

    $trans_ext[chr(149)] = '&bull;';    // Bullet

    $trans_ext[chr(150)] = '&ndash;';    // En Dash

    $trans_ext[chr(151)] = '&mdash;';    // Em Dash

    $trans_ext[chr(152)] = '&tilde;';    // Small Tilde

    $trans_ext[chr(153)] = '&trade;';    // Trade Mark Sign

    $trans_ext[chr(154)] = '&scaron;';    // Latin Small Letter S With Caron

    $trans_ext[chr(155)] = '&rsaquo;';    // Single Right-Pointing Angle Quotation Mark

    $trans_ext[chr(156)] = '&oelig;';    // Latin Small Ligature OE

    $trans_ext[chr(159)] = '&Yuml;';    // Latin Capital Letter Y With Diaeresis

	

//	$trans_ext[chr(255)] = '&yuml;';

//	$trans_ext[chr(338)] = '&OElig;';

//	$trans_ext[chr(339)] = '&oelig;';

//	$trans_ext[chr(352)] = '&Scaron;';

//	$trans_ext[chr(353)] = '&scaron;';

//	$trans_ext[chr(376)] = '&Yuml;';

//	$trans_ext[chr(402)] = '&fnof;';

//	$trans_ext[chr(710)] = '&circ;';

//	$trans_ext[chr(732)] = '&tilde;';

//	$trans_ext[chr(913)] = '&Alpha;';

//	$trans_ext[chr(914)] = '&Beta;';

//	$trans_ext[chr(915)] = '&Gamma;';

//	$trans_ext[chr(916)] = '&Delta;';

//	$trans_ext[chr(917)] = '&Epsilon;';

//	$trans_ext[chr(918)] = '&Zeta;';

//	$trans_ext[chr(919)] = '&Eta;';

//	$trans_ext[chr(920)] = '&Theta;';

//	$trans_ext[chr(921)] = '&Iota;';

//	$trans_ext[chr(922)] = '&Kappa;';

//	$trans_ext[chr(923)] = '&Lambda;';

//	$trans_ext[chr(924)] = '&Mu;';

//	$trans_ext[chr(925)] = '&Nu;';

//	$trans_ext[chr(926)] = '&Xi;';

//	$trans_ext[chr(927)] = '&Omicron;';

//	$trans_ext[chr(928)] = '&Pi;';

//	$trans_ext[chr(929)] = '&Rho;';

//	$trans_ext[chr(931)] = '&Sigma;';

//	$trans_ext[chr(932)] = '&Tau;';

//	$trans_ext[chr(933)] = '&Upsilon;';

//	$trans_ext[chr(934)] = '&Phi;';

//	$trans_ext[chr(935)] = '&Chi;';

//	$trans_ext[chr(936)] = '&Psi;';

//	$trans_ext[chr(937)] = '&Omega;';

//	$trans_ext[chr(945)] = '&alpha;';

//	$trans_ext[chr(946)] = '&beta;';

//	$trans_ext[chr(947)] = '&gamma;';

//	$trans_ext[chr(948)] = '&delta;';

//	$trans_ext[chr(949)] = '&epsilon;';

//	$trans_ext[chr(950)] = '&zeta;';

//	$trans_ext[chr(951)] = '&eta;';

//	$trans_ext[chr(952)] = '&theta;';

//	$trans_ext[chr(953)] = '&iota;';

//	$trans_ext[chr(954)] = '&kappa;';

//	$trans_ext[chr(955)] = '&lambda;';

//	$trans_ext[chr(956)] = '&mu;';

//	$trans_ext[chr(957)] = '&nu;';

//	$trans_ext[chr(958)] = '&xi;';

//	$trans_ext[chr(959)] = '&omicron;';

//	$trans_ext[chr(960)] = '&pi;';

//	$trans_ext[chr(961)] = '&rho;';

//	$trans_ext[chr(962)] = '&sigmaf;';

//	$trans_ext[chr(963)] = '&sigma;';

//	$trans_ext[chr(964)] = '&tau;';

//	$trans_ext[chr(965)] = '&upsilon;';

//	$trans_ext[chr(966)] = '&phi;';

//	$trans_ext[chr(967)] = '&chi;';

//	$trans_ext[chr(968)] = '&psi;';

//	$trans_ext[chr(969)] = '&omega;';

//	$trans_ext[chr(977)] = '&thetasym;';

//	$trans_ext[chr(978)] = '&upsih;';

//	$trans_ext[chr(982)] = '&piv;';

//	$trans_ext[chr(8194)] = '&ensp;';

//	$trans_ext[chr(8195)] = '&emsp;';

//	$trans_ext[chr(8201)] = '&thinsp;';

//	$trans_ext[chr(8204)] = '&zwnj;';

//	$trans_ext[chr(8205)] = '&zwj;';

//	$trans_ext[chr(8206)] = '&lrm;';

//	$trans_ext[chr(8207)] = '&rlm;';

//	$trans_ext[chr(8211)] = '&ndash;';

//	$trans_ext[chr(8212)] = '&mdash;';

//	$trans_ext[chr(8216)] = '&lsquo;';

//	$trans_ext[chr(8217)] = '&rsquo;';

//	$trans_ext[chr(8218)] = '&sbquo;';

//	$trans_ext[chr(8220)] = '&ldquo;';

//	$trans_ext[chr(8221)] = '&rdquo;';

//	$trans_ext[chr(8222)] = '&bdquo;';

//	$trans_ext[chr(8224)] = '&dagger;';

//	$trans_ext[chr(8225)] = '&Dagger;';

//	$trans_ext[chr(8226)] = '&bull;';

//	$trans_ext[chr(8230)] = '&hellip;';

//	$trans_ext[chr(8240)] = '&permil;';

//	$trans_ext[chr(8242)] = '&prime;';

//	$trans_ext[chr(8243)] = '&Prime;';

//	$trans_ext[chr(8249)] = '&lsaquo;';

//	$trans_ext[chr(8250)] = '&rsaquo;';

//	$trans_ext[chr(8254)] = '&oline;';

//	$trans_ext[chr(8260)] = '&frasl;';

//	$trans_ext[chr(8364)] = '&euro;';

//	$trans_ext[chr(8465)] = '&image;';

//	$trans_ext[chr(8472)] = '&weierp;';

//	$trans_ext[chr(8476)] = '&real;';

//	$trans_ext[chr(8482)] = '&trade;';

//	$trans_ext[chr(8501)] = '&alefsym;';

//	$trans_ext[chr(8592)] = '&larr;';

//	$trans_ext[chr(8593)] = '&uarr;';

//	$trans_ext[chr(8594)] = '&rarr;';

//	$trans_ext[chr(8595)] = '&darr;';

//	$trans_ext[chr(8596)] = '&harr;';

//	$trans_ext[chr(8629)] = '&crarr;';

//	$trans_ext[chr(8656)] = '&lArr;';

//	$trans_ext[chr(8657)] = '&uArr;';

//	$trans_ext[chr(8658)] = '&rArr;';

//	$trans_ext[chr(8659)] = '&dArr;';

//	$trans_ext[chr(8660)] = '&hArr;';

//	$trans_ext[chr(8704)] = '&forall;';

//	$trans_ext[chr(8706)] = '&part;';

//	$trans_ext[chr(8707)] = '&exist;';

//	$trans_ext[chr(8709)] = '&empty;';

//	$trans_ext[chr(8711)] = '&nabla;';

//	$trans_ext[chr(8712)] = '&isin;';

//	$trans_ext[chr(8713)] = '&notin;';

//	$trans_ext[chr(8715)] = '&ni;';

//	$trans_ext[chr(8719)] = '&prod;';

//	$trans_ext[chr(8721)] = '&sum;';

//	$trans_ext[chr(8722)] = '&minus;';

//	$trans_ext[chr(8727)] = '&lowast;';

//	$trans_ext[chr(8730)] = '&radic;';

//	$trans_ext[chr(8733)] = '&prop;';

//	$trans_ext[chr(8734)] = '&infin;';

//	$trans_ext[chr(8736)] = '&ang;';

//	$trans_ext[chr(8743)] = '&and;';

//	$trans_ext[chr(8744)] = '&or;';

//	$trans_ext[chr(8745)] = '&cap;';

//	$trans_ext[chr(8746)] = '&cup;';

//	$trans_ext[chr(8747)] = '&int;';

//	$trans_ext[chr(8756)] = '&there4;';

//	$trans_ext[chr(8764)] = '&sim;';

//	$trans_ext[chr(8773)] = '&cong;';

//	$trans_ext[chr(8776)] = '&asymp;';

//	$trans_ext[chr(8800)] = '&ne;';

//	$trans_ext[chr(8801)] = '&equiv;';

//	$trans_ext[chr(8804)] = '&le;';

//	$trans_ext[chr(8805)] = '&ge;';

//	$trans_ext[chr(8834)] = '&sub;';

//	$trans_ext[chr(8835)] = '&sup;';

//	$trans_ext[chr(8836)] = '&nsub;';

//	$trans_ext[chr(8838)] = '&sube;';

//	$trans_ext[chr(8839)] = '&supe;';

//	$trans_ext[chr(8853)] = '&oplus;';

//	$trans_ext[chr(8855)] = '&otimes;';

//	$trans_ext[chr(8869)] = '&perp;';

//	$trans_ext[chr(8901)] = '&sdot;';

//	$trans_ext[chr(8968)] = '&lceil;';

//	$trans_ext[chr(8969)] = '&rceil;';

//	$trans_ext[chr(8970)] = '&lfloor;';

//	$trans_ext[chr(8971)] = '&rfloor;';

//	$trans_ext[chr(9001)] = '&lang;';

//	$trans_ext[chr(9002)] = '&rang;';

//	$trans_ext[chr(9674)] = '&loz;';

//	$trans_ext[chr(9824)] = '&spades;';

//	$trans_ext[chr(9827)] = '&clubs;';

//	$trans_ext[chr(9829)] = '&hearts;';

//	$trans_ext[chr(9830)] = '&diams;';



	//echo "after extra chars"; echo "<br>"; print_r($trans_ext); echo "<br>";



//$final_trans = array_merge($trans, $trans_ext);

	

		//echo "after merge"; echo "<br>"; print_r($final_trans); echo "<br>";



//	$trans_ext[126] = '&tilde;';

//	$trans_ext[130] = '&sbquo;';    // Single Low-9 Quotation Mark

//    $trans_ext[131] = '&fnof;';    // Latin Small Letter F With Hook

//    $trans_ext[132] = '&bdquo;';    // Double Low-9 Quotation Mark

//    $trans_ext[133] = '&hellip;';    // Horizontal Ellipsis

//    $trans_ext[134] = '&dagger;';    // Dagger

//    $trans_ext[135] = '&Dagger;';    // Double Dagger

//    $trans_ext[136] = '&circ;';    // Modifier Letter Circumflex Accent

//    $trans_ext[137] = '&permil;';    // Per Mille Sign

//    $trans_ext[138] = '&Scaron;';    // Latin Capital Letter S With Caron

//    $trans_ext[139] = '&lsaquo;';    // Single Left-Pointing Angle Quotation Mark

//    $trans_ext[140] = '&OElig;    ';    // Latin Capital Ligature OE

//    $trans_ext[145] = '&lsquo;';    // Left Single Quotation Mark

//    $trans_ext[146] = '&rsquo;';    // Right Single Quotation Mark

//    $trans_ext[147] = '&ldquo;';    // Left Double Quotation Mark

//    $trans_ext[148] = '&rdquo;';    // Right Double Quotation Mark

//    $trans_ext[149] = '&bull;';    // Bullet

//    $trans_ext[150] = '&ndash;';    // En Dash

//    $trans_ext[151] = '&mdash;';    // Em Dash

//    $trans_ext[152] = '&tilde;';    // Small Tilde

//    $trans_ext[153] = '&trade;';    // Trade Mark Sign

//    $trans_ext[154] = '&scaron;';    // Latin Small Letter S With Caron

//    $trans_ext[155] = '&rsaquo;';    // Single Right-Pointing Angle Quotation Mark

//    $trans_ext[156] = '&oelig;';    // Latin Small Ligature OE

//    $trans_ext[159] = '&Yuml;';    // Latin Capital Letter Y With Diaeresis

	

	



//	$trans[255] = '&yuml;';

//	$trans[338] = '&OElig;';

//	$trans[339] = '&oelig;';

//	$trans[352] = '&Scaron;';

//	$trans[353] = '&scaron;';

//	$trans[376] = '&Yuml;';

//	$trans[402] = '&fnof;';

//	$trans[710] = '&circ;';

//	$trans[732] = '&tilde;';

//	$trans[913] = '&Alpha;';

//	$trans[914] = '&Beta;';

//	$trans[915] = '&Gamma;';

//	$trans[916] = '&Delta;';

//	$trans[917] = '&Epsilon;';

//	$trans[918] = '&Zeta;';

//	$trans[919] = '&Eta;';

//	$trans[920] = '&Theta;';

//	$trans[921] = '&Iota;';

//	$trans[922] = '&Kappa;';

//	$trans[923] = '&Lambda;';

//	$trans[924] = '&Mu;';

//	$trans[925] = '&Nu;';

//	$trans[926] = '&Xi;';

//	$trans[927] = '&Omicron;';

//	$trans[928] = '&Pi;';

//	$trans[929] = '&Rho;';

//	$trans[931] = '&Sigma;';

//	$trans[932] = '&Tau;';

//	$trans[933] = '&Upsilon;';

//	$trans[934] = '&Phi;';

//	$trans[935] = '&Chi;';

//	$trans[936] = '&Psi;';

//	$trans[937] = '&Omega;';

//	$trans[945] = '&alpha;';

//	$trans[946] = '&beta;';

//	$trans[947] = '&gamma;';

//	$trans[948] = '&delta;';

//	$trans[949] = '&epsilon;';

//	$trans[950] = '&zeta;';

//	$trans[951] = '&eta;';

//	$trans[952] = '&theta;';

//	$trans[953] = '&iota;';

//	$trans[954] = '&kappa;';

//	$trans[955] = '&lambda;';

//	$trans[956] = '&mu;';

//	$trans[957] = '&nu;';

//	$trans[958] = '&xi;';

//	$trans[959] = '&omicron;';

//	$trans[960] = '&pi;';

//	$trans[961] = '&rho;';

//	$trans[962] = '&sigmaf;';

//	$trans[963] = '&sigma;';

//	$trans[964] = '&tau;';

//	$trans[965] = '&upsilon;';

//	$trans[966] = '&phi;';

//	$trans[967] = '&chi;';

//	$trans[968] = '&psi;';

//	$trans[969] = '&omega;';

//	$trans[977] = '&thetasym;';

//	$trans[978] = '&upsih;';

//	$trans[982] = '&piv;';

//	$trans[8194] = '&ensp;';

//	$trans[8195] = '&emsp;';

//	$trans[8201] = '&thinsp;';

//	$trans[8204] = '&zwnj;';

//	$trans[8205] = '&zwj;';

//	$trans[8206] = '&lrm;';

//	$trans[8207] = '&rlm;';

//	$trans[8211] = '&ndash;';

//	$trans[8212] = '&mdash;';

//	$trans[8216] = '&lsquo;';

//	$trans[8217] = '&rsquo;';

//	$trans[8218] = '&sbquo;';

//	$trans[8220] = '&ldquo;';

//	$trans[8221] = '&rdquo;';

//	$trans[8222] = '&bdquo;';

//	$trans[8224] = '&dagger;';

//	$trans[8225] = '&Dagger;';

//	$trans[8226] = '&bull;';

//	$trans[8230] = '&hellip;';

//	$trans[8240] = '&permil;';

//	$trans[8242] = '&prime;';

//	$trans[8243] = '&Prime;';

//	$trans[8249] = '&lsaquo;';

//	$trans[8250] = '&rsaquo;';

//	$trans[8254] = '&oline;';

//	$trans[8260] = '&frasl;';

//	$trans[8364] = '&euro;';

//	$trans[8465] = '&image;';

//	$trans[8472] = '&weierp;';

//	$trans[8476] = '&real;';

//	$trans[8482] = '&trade;';

//	$trans[8501] = '&alefsym;';

//	$trans[8592] = '&larr;';

//	$trans[8593] = '&uarr;';

//	$trans[8594] = '&rarr;';

//	$trans[8595] = '&darr;';

//	$trans[8596] = '&harr;';

//	$trans[8629] = '&crarr;';

//	$trans[8656] = '&lArr;';

//	$trans[8657] = '&uArr;';

//	$trans[8658] = '&rArr;';

//	$trans[8659] = '&dArr;';

//	$trans[8660] = '&hArr;';

//	$trans[8704] = '&forall;';

//	$trans[8706] = '&part;';

//	$trans[8707] = '&exist;';

//	$trans[8709] = '&empty;';

//	$trans[8711] = '&nabla;';

//	$trans[8712] = '&isin;';

//	$trans[8713] = '&notin;';

//	$trans[8715] = '&ni;';

//	$trans[8719] = '&prod;';

//	$trans[8721] = '&sum;';

//	$trans[8722] = '&minus;';

//	$trans[8727] = '&lowast;';

//	$trans[8730] = '&radic;';

//	$trans[8733] = '&prop;';

//	$trans[8734] = '&infin;';

//	$trans[8736] = '&ang;';

//	$trans[8743] = '&and;';

//	$trans[8744] = '&or;';

//	$trans[8745] = '&cap;';

//	$trans[8746] = '&cup;';

//	$trans[8747] = '&int;';

//	$trans[8756] = '&there4;';

//	$trans[8764] = '&sim;';

//	$trans[8773] = '&cong;';

//	$trans[8776] = '&asymp;';

//	$trans[8800] = '&ne;';

//	$trans[8801] = '&equiv;';

//	$trans[8804] = '&le;';

//	$trans[8805] = '&ge;';

//	$trans[8834] = '&sub;';

//	$trans[8835] = '&sup;';

//	$trans[8836] = '&nsub;';

//	$trans[8838] = '&sube;';

//	$trans[8839] = '&supe;';

//	$trans[8853] = '&oplus;';

//	$trans[8855] = '&otimes;';

//	$trans[8869] = '&perp;';

//	$trans[8901] = '&sdot;';

//	$trans[8968] = '&lceil;';

//	$trans[8969] = '&rceil;';

//	$trans[8970] = '&lfloor;';

//	$trans[8971] = '&rfloor;';

//	$trans[9001] = '&lang;';

//	$trans[9002] = '&rang;';

//	$trans[9674] = '&loz;';

//	$trans[9824] = '&spades;';

//	$trans[9827] = '&clubs;';

//	$trans[9829] = '&hearts;';

//	$trans[9830] = '&diams;';

	

	

	

	//echo "before sort"; echo "<br>"; print_r($trans_ext); echo "<br>";

	

    //ksort($trans_ext);

	

	//echo "after sort"; echo "<br>"; print_r($trans_ext); echo "<br>";

	

    return $trans_ext;

}



function htmlentities2unicodeentities ($input) {

  //$htmlEntities = array_values (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));

  //$entitiesDecoded = array_keys   (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));

 



   $htmlEntities = array_values (get_html_translation_table_extended ());

  $entitiesDecoded = array_keys   (get_html_translation_table_extended ());

 

  //echo "before extend"; echo "<br>"; print_r($htmlEntities_orig); echo "<br>";



  //echo "key :";  print_r($entitiesDecoded); echo "<br>"; echo "<br>";

  //echo "value :";  print_r($htmlEntities); echo "<br>";

  

  $num = count ($entitiesDecoded);

  

  //echo "input="; echo $input; echo "<br>";

  

  //echo "num="; echo $num; echo "<br>";

  

  for ($u = 0; $u < $num; $u++) {

    $utf8Entities[$u] = '&#'.ord($entitiesDecoded[$u]).';';

	

	//echo $u; echo " html : "; echo $htmlEntities[$u]; echo " decoded : "; $entitiesDecoded[$u]; echo " utf8 : "; echo $utf8Entities[$u]; echo "<br>";

  }

  



  return str_replace ($htmlEntities, $utf8Entities, $input);

}



/* 

Need a add a safegauard to protect people from access other listings

Just need to add a check that looks at the session id adn OID to verify



Matt

 */





$ListingID = $_GET['listing_id'];

require("../db/opendb.php");

$if_add = false;



if (isset($_POST["update"]))

{

$Proptype = "";

$Streetdir="";

$Streetname="";

$Streetnum="";

$Streetsuffix="";

$Unit="";

$City="";

$County="";

$State="";

$Zip="";

$Longitude="";

$Latitude="";

$Price="";

$SoldPrice="";

$Listdate="";

$SoldDate="";

$Beds="";

$Bathsfull="";

$Bathshalf="";

$Bathstotal="";

$Sqft="";

$Parking="";

$Stories="";

$ML_Number="";

$Description="";

$Style = "";

$Yearbuilt="";

$HOA="";

$Title="";

$VT = "";

$Landing_Page="";

$FSBO="";

$Website = "";

$IVR = "";

$Status = "";

$Zillow_Quicklink = "";



$Proptype=$_POST['prop_type'];

$Status = $_POST['listingstatus'];

$Streetdir=$_POST['street_direction'];

$Streetnum=$_POST['street_number'];

$Streetname=$_POST['street_name'];

$Streetsuffix=$_POST['street_suffix'];

$Unit=$_POST['unit'];

$City=$_POST['city'];

$County=$_POST['county'];

$State=$_POST['state'];

$Zip=$_POST['zip'];

$Price=$_POST['price'];

$Price = str_replace("$", "", $Price);

$Price = str_replace(",", "", $Price);

$SoldPrice=$_POST['soldprice'];

$SoldPrice = str_replace("$", "", $SoldPrice);

$SoldPrice = str_replace(",", "", $SoldPrice);

$HOA=$_POST['hoa'];

$ListDate=$_POST['listdateyear']."-".$_POST['listdatemonth']."-".$_POST['listdateday'];

$SoldDate=$_POST['solddateyear']."-".$_POST['solddatemonth']."-".$_POST['solddateday'];

$Beds=$_POST['beds'];

$Bathsfull=$_POST['baths_full'];

$Bathshalf=$_POST['baths_half'];

$Bathstotal=$_POST['baths_total'];

$Sqft=$_POST['sqft'];

$Parking=$_POST['parking'];

$Stories=$_POST['stories'];

$ML_Number=$_POST['ml_number'];

$Description=stripslashes($_POST['description']);

$Style=$_POST['style'];

$Yearbuilt=$_POST['yearbuilt'];

$Listingagent=$_POST['listing_agent'];

$Listingcompany=$_POST['listing_company'];

$Title=stripslashes($_POST['title']);

$VT = $_POST['vt'];

$Landing_Page=$_POST['landing_page'];

$FSBO=$_POST['fsbo'];

$LISTINGAGENT=$_POST['listingagent'];

$Website = $_POST['website'];

$IVR = $_POST['ivr'];

$Zillow_Quicklink=$_POST['zillow_quicklink'];





if($LISTINGAGENT == 'Yes')

{

$listingagent_val = $_SESSION['id'];

}

else

{

$listingagent_val = -1;

}



//echo "Orig Description="; echo $Description; echo "<br>";



$tmpREMARKS = convertDoc2HTML($Description);



//echo "tmpREMARKS="; echo $tmpREMARKS; echo "<br>";



$newREMARKS = htmlentities2unicodeentities($tmpREMARKS);



//echo "newREMARKS="; echo $newREMARKS; echo "<br>";



//echo "listingstatus="; echo $Status; echo "<br>";

//echo "Streetdir="; echo $Streetdir; echo "<br>";

//echo "Streetsuffix="; echo $Streetsuffix; echo "<br>";



//echo "Description="; echo $Description; echo "<br>";



// get lat lof



//		$q = $q = $Streetnum." ".$Streetname. ", " . $_POST["city"]. " " . $_POST["state"]. " " . $_POST["zip"];

//		$base = $PHP_SELF . "?address=" . $q ;

//		$filler = "http://rpc.geocoder.us/service/csv?address=" . (urlencode($q));

//		$gm = fopen($filler,"r");

//		$tmp = fgetcsv($gm,8000);

//		fclose($gm);

//		$la = $tmp["0"];

//		$lo = $tmp["1"];

//		$Longitude="";

//		$Latitude="";

//				

//

//		if(is_numeric($la))

//		{

//			$Longitude=$lo;

//			$Latitude=$la;

//			//echo "<BR>Geocoder US Long: ".$lo." Lat: ".$la;

//

//				

//		}

//		else

//		{

		$str = 'http://maps.google.com/maps/geo?q=';

		if($Streetsuffix != "")

		{

		if($Streetdir != "")

		{

		$str .= urlencode($Streetnum)."+".urlencode($Streetdir)."+".urlencode($Streetname)."+".urlencode($Streetsuffix).",+" . urlencode($City). ",+" . urlencode($State). ",+" . $Zip;



		}

		else

		{

		$str .= urlencode($Streetnum)."+".urlencode($Streetname)."+".urlencode($Streetsuffix).",+" . urlencode($City). ",+" . urlencode($State). ",+" . $Zip;

		}

		}

		else

		{

		if($Streetdir != "")

		{

		$str .= urlencode($Streetnum)."+".urlencode($Streetdir)."+".urlencode($Streetname).",+" . urlencode($City). ",+" . urlencode($State);



		}

		else

		{

		$str .= urlencode($Streetnum)."+".urlencode($Streetname).",+" . urlencode($City). ",+" . urlencode($State);

		}

		}



		$str .= '&output=xml&key=ABQIAAAAbD1g7tn1oepwso-UqvURVhQEdUgRdbLWZHDJeWpYfhZ5x1O-ExR0wh8BG55rhk8ouAQdlJiAnq7OJQ';

		

		//echo "Google string=";

		//echo $str.'<BR><BR>';

		

		$ch = curl_init($str); 

        //curl_setopt($ch, CURLOPT_HEADER, 0); 

        //curl_setopt($ch, CURLOPT_POST, 1); 

        //curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring); 

       // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        $data = curl_exec($ch); 

        curl_close($ch); 

       

		$prop = &new Prop_Parser();

		$prop->setInputString($data);

		$success = $prop->parse();

		if (PEAR::isError($success)) 

			{

			  die('Parsing failed:' . $success->getMessage());

			}

		

		$result = $prop->getProperties();

		$lonlat2 = explode(",", $result['coordinates']);

		$lo = $lonlat2[0];

		$la = $lonlat2[1];



			if(is_numeric($la))

			{

				$Longitude=$lo;

				$Latitude=$la;

				//echo "<BR>Google Long: ".$lo." Lat: ".$la;

				

			}



		//print_r($prop);



//		}

		

		

		if(!(is_numeric($la)))



		{

		//$str = "street=".urlencode($Streetnum).urlencode($Streetname).urlencode($Streetsuffix)."&city=" . urlencode($City). "&state=" . $State. "&zip=" . $Zip;

		

		//$str = "street=".urlencode($Streetnum)."+".urlencode($Streetname)."+".urlencode($Streetsuffix)."&city=" . urlencode($City). "&state=" . $State. "&zip=" . $Zip;



			$str = "street=".urlencode($Streetnum)."+".urlencode($Streetdir)."+".urlencode($Streetname)."+".urlencode($Streetsuffix)."&city=" . urlencode($City). "&state=" . $State. "&zip=" . $Zip;



	

		//echo $str;



		//$str = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=freebee&".$str."&output=php";



		$str = "http://local.yahooapis.com/MapsService/V1/geocode?appid=freebee&".$str;



		//echo $str;

			

		$coord_result = simplexml_load_file($str);

		

			

		//print_r($coord_result);

		

		$la = $coord_result->Result->Latitude;

		$lo = $coord_result->Result->Longitude;



//		echo "Yahoo_Cords:";

//		echo "<br>";

//		echo $la;

//		echo "<br>";

//		echo $lo;

//		echo "<br>";

//	

			if($la)

			{

				$Longitude=$lo;

				$Latitude=$la;

				//echo "<BR>Yahoo Long: ".$lo." Lat: ".$la;

				

			}

		

			

		//$response = file_get_contents($str);



//		if ($response === false) 

//			{

//				die('Request failed');

//			}

//		

//			$phpobj = unserialize($response);

//

//			$items = $phpobj['ResultSet'];

//			$result = $items['Result'];

//	

//			$lo = $result['Longitude'];

//			$la = $result['Latitude'];

//			

//			if(is_numeric($la))

//			{

//				$Longitude=$lo;

//				$Latitude=$la;

//				//echo "<BR>Long: ".$lo." Lat: ".$la;

//				

//			}



		}



	

	$insertquery = "update PROPERTIES set ";

	$insertquery = $insertquery." PROPTYPE='".$Proptype."',";

	$insertquery = $insertquery." STREETDIR='".$Streetdir."',";

	$insertquery = $insertquery." STREETNAME='".$Streetname."',";

	$insertquery = $insertquery." STREETNUM='".$Streetnum."',";

	$insertquery = $insertquery." STREETSUFFIX='".$Streetsuffix."',";

	$insertquery = $insertquery." UNITFLOORNUM='".$Unit."',";

	$insertquery = $insertquery." CITY='".$City."',";

	$insertquery = $insertquery." STATE='".$State."',";

	$insertquery = $insertquery." ZIPCODE='".$Zip."',";	

	

	//switched

	$insertquery = $insertquery." LONGITUDE='".$Longitude."',";	

	$insertquery = $insertquery." LATITUDE='".$Latitude."',";	

	$insertquery = $insertquery." LISTPRICE='".$Price."',";	

	$insertquery = $insertquery." SALESPRICE='".$SoldPrice."',";	

	$insertquery = $insertquery." ASSOCFEE='".$HOA."',";

	$insertquery = $insertquery." LISTDATE='".$ListDate."',";	

	$insertquery = $insertquery." OFFMARKETDATE='".$SoldDate."',";		

	$insertquery = $insertquery." BEDS='".$Beds."',";	

	$insertquery = $insertquery." BATHSFULL='".$Bathsfull."',";	

	$insertquery = $insertquery." BATHSHALF='".$Bathshalf."',";	

	$insertquery = $insertquery." BATHSTOTAL='".$Bathstotal."',";	

	$insertquery = $insertquery." SQFTTOTAL='".$Sqft."',";	

	$insertquery = $insertquery." PARKINGCOVERED='".$Parking."',";

	$insertquery = $insertquery." STORIES='".$Stories."',";	

	$insertquery = $insertquery." MLSNUM='".$ML_Number."',";

	//$insertquery = $insertquery." REMARKS='".$Description."',";	

	$insertquery = $insertquery." REMARKS='".$newREMARKS."',";	

	//$insertquery = $insertquery." LISTING_AGENT='".$Listingagent."',";

	$insertquery = $insertquery." LISTING_AGENT='".$listingagent_val."',";

	$insertquery = $insertquery." LISTING_COMPANY='".$Listingcompany."',";		

	$insertquery = $insertquery." STYLE='".$Style."',";

	$insertquery = $insertquery." LANDING_PAGE='".$Landing_Page."',";

	$insertquery = $insertquery." VIRTUAL_TOUR_URL='".$VT."',";

	$insertquery = $insertquery." TITLE='".$Title."',";

	$insertquery = $insertquery." FSBO='".$FSBO."',";

	$insertquery = $insertquery." display_zillow='".$Zillow_Quicklink."',";

	$insertquery = $insertquery." IVR='".$IVR."',";

	if($Status != '')

	{

	$insertquery = $insertquery." LISTSTATUS='".$Status."',";

	}

	

	$insertquery = $insertquery." YEARBUILT='".$Yearbuilt."',";

	if ($_POST["visible"])

	$insertquery = $insertquery." VISIBLE='1'";

	else

	$insertquery = $insertquery." VISIBLE='0'";

	

	$insertquery = $insertquery." where OID=".$ListingID;	

	

	//echo $insertquery;

	

	mysql_query($insertquery) or die(mysql_error()); 

	

	

	

	//delete the current property features, and then refill

	$dsql = "DELETE from Prop_Features where Listing_ID = '".$ListingID."'";

	$dresult = mysql_query($dsql) or die ("SQL Error".mysql_error());

	

	

	if($array =  $_POST['kitchen_features'])

	{

		foreach($array as $kf)

		{

			$ksql = "insert into Prop_Features (Listing_ID, Type, Feature) Values ('".$ListingID."','Kitchen','".$kf."')";

			$kresult = mysql_query($ksql) or die ("SQL Error".mysql_error());

		}

	}

	

	if($array =  $_POST['interior_features'])

	{

		foreach($array as $kf)

		{

			$ksql = "insert into Prop_Features (Listing_ID, Type, Feature) Values ('".$ListingID."','Interior','".$kf."')";

			$kresult = mysql_query($ksql) or die ("SQL Error".mysql_error());

		}

	}

	

	if($array =  $_POST['exterior_features'])

	{

		foreach($array as $kf)

		{

			$ksql = "insert into Prop_Features (Listing_ID, Type, Feature) Values ('".$ListingID."','Exterior','".$kf."')";

			$kresult = mysql_query($ksql) or die ("SQL Error".mysql_error());

		}

	}

	

	

	

	$message = "The listing information has been updated successfully. <br>";



$if_add = true;

}



//get user information

$query = "select * from Users where ID='".$_SESSION["id"]."'";

$result = mysql_query($query) or die ("SQL Error".mysql_error());

$row=mysql_fetch_assoc($result);

?>





<body>

<center>
<table align="center" width="1000" border="0" cellspacing="0" cellpadding="0">

<tr><td><?php include('accounts_top_navigation.php'); ?></td></tr>



<tr>

<tr style="font-size:18px; color:#FF6600"><td>

<br/>

<div style="font-size:18px">

	<!--   
	<div style="float:right; width:250px;">

		<a href=invite_contacts.php><img border="0" src=../images/add_network.gif align="right"></a>

		</div>-->

		

		

	</div>





</td></tr>

  <tr>

    <td valign="top" style="height:300px;">

	<table width="100%"  border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="150" valign="top" align="left">

	<Div id=menu_column>

	<?php
		 if(isset($_SESSION['id']) && $row['disp_profile'] != 'No')
		 { 
		 include("accounts_left_navigation.php");
		 }
		 ?>


	  </Div>

     </td>

	 

    <td width="850" valign="top" align="left" id=main_body>

	

	

    	  			<div style="float:left" id=property_title>

				

				<?php 

				if($ListingID != 0){include('change_listing_include.php');}

				 ?>

				</div>

	 			<BR><BR>

	 

	<div id="invertedtabsline">&nbsp;</div>

	 <?php include('listing_menu_control.php'); ?>

		<BR><BR>



  

	  <?

	  

	

	  	$lquery = "select * from PROPERTIES p inner join Prop_Owner_Con c on p.OID = c.Prop_OID where p.OID='".$ListingID."' and c.Owner = '".$_SESSION['id']."'";

		$lresult = mysql_query($lquery) or die ("SQL Error".mysql_error());

		$listing_row=mysql_fetch_assoc($lresult);



//echo "database listing status="; echo $listing_row['LISTSTATUS']; echo "<br>";		



		if (mysql_num_rows($lresult) === 0)

		{

			echo "You have not entered a listing yet or you do not have permission to edit this listing.";

		}

		else

		{

	  

	  ?>

	 <table width="100%" border="0" cellspacing="0" cellpadding="0">

		  <tr>

			<td valign="top">

			<?php echo "<font color=red>".$message."</font><BR>"; ?> 

			

			<form  name="listing_form" action="edit_listing.php?listing_id=<?php echo $ListingID ?>" method="post" enctype="application/x-www-form-urlencoded">

			

						<div style="padding:5px;"><strong>Listing Status: </strong>

			<select name="listingstatus" id="lstatus">

			<option value="ACTIVE">Active</option>

			<option value="PENDING">Pending</option>

			<option value="SOLD">Sold</option>

			<option value="WITHDRAWN">Withdrawn</option>

			<option value="EXPIRED">Expired</option>

			<option value="DO_NOT_DISPLAY">Do Not Display</option>
			<option value="COMMING_SOON">Comming Soon...</option>
			</select>

			<script language="javascript" type="text/javascript">

				  var cval = '<?php echo $listing_row['LISTSTATUS']; ?>';

						for(i=0;i<document.forms[1].listingstatus.options.length;i++)

							if(document.forms[1].listingstatus.options[i].value==cval)

								document.forms[1].listingstatus.options[i].selected=true;

					</script>

					

					

			

			 <br />

			 <br />



			</div>



			<div><strong>Property Header</strong><br />

			  <input type="text" style="width:95%" name="title" value = '<?php echo $listing_row['TITLE']; ?>'/>

			  <br />

			  <span class="style4">example: gorgeous 3-2 with large yard, great location, ready to deal!</span> <br />

			  <br />

			</div>

			



			<div><strong>Property Address</strong></div>

			<table width="100%" border="0" cellspacing="0" cellpadding="3">

			 

			  <TR>

			  	 <td width="11%" align="left"><span class="style1">Number:</span><BR />

			  	   <input name="street_number" type="text" size=5 id="street_number" class="text" value="<?php echo $listing_row['STREETNUM']; ?>" /></td>

				   <td width="13%" align="left"><span class="style1">Direction:</span><BR />

				     <select name="street_direction" id="dir">

				<option value=""> </option>

					<option value='N'>N</option>

					<option value='E'>E</option>

					<option value='S'>S</option>

					<option value='W'>W</option>

					<option value='NE'>NE</option>

					<option value='NW'>NW</option>

					<option value='SE'>SE</option>

					<option value='SW'>SW</option>

				</select>

				 <script language="JavaScript" type="text/javascript">

				  var cval = '<?php echo $listing_row['STREETDIR']; ?>';

						for(i=0;i<document.forms[1].street_direction.options.length;i++)

							if(document.forms[1].street_direction.options[i].value==cval)

								document.forms[1].street_direction.options[i].selected=true;

					</script>

				</td>

				   <td width="30%" align="left"><span class="style1">Street Name:</span><br />

				   <input name="street_name" type="text" id="street_name" class="text" value="<?php echo $listing_row['STREETNAME']; ?>" /></td>

				    <td width="8%" align="left"><span class="style1">Suffix:</span><BR />

				      <select name=street_suffix id=suffix>

				<option value=""> </option>

				<?php 

					$pquery = "select * from Street_Suffix";

					$presult = mysql_query($pquery) or die ("SQL Error".mysql_error());

					while($prop_row=mysql_fetch_assoc($presult))

					{

						if($listing_row['STREETSUFFIX'] === $prop_row['Value'])

						{

					?>

						<option value=<?php echo $prop_row['Value']; ?> selected="selected"><?php echo $prop_row['Name']; ?></option>

					<?

						}

						else

						{

					?>

						<option value=<?php echo $prop_row['Value']; ?>><?php echo $prop_row['Name']; ?></option>

					<?

						}

					}

					?>

				</select></td>

				    <td width="38%" align="left"><span class="style1">Unit:</span><BR />

			        <input name="unit" type="text" class="text" id="unit" size=5 value='<?php echo $listing_row['UNITFLOORNUM']; ?>' /></td>

			  </TR>

			  <TR>

			  	<TD colspan="5">

					<table width="100%" border="0" cellspacing="0" cellpadding="0">

					  <tr>

						<td width="32%" align="left"><span class="style1">City:<BR />

						</span>

						  <input name="city" type="text" class="text" id="city" value='<?php echo $listing_row['CITY']; ?>' /></td>

						<td width="15%"><span class="style1">State:</span><BR />

						<select name=state id=state>

							<option value="AL">AL</option>

							<option value="AK">AK</option>

							<option value="AZ">AZ</option>

							<option value="AR">AR</option>

							<option value="CA">CA</option>

							<option value="CO">CO</option>

							<option value="CT">CT</option>

							<option value="DE">DE</option>

							<option value="DC">DC</option>

							<option value="FL">FL</option>

							<option value="GA">GA</option>

							<option value="HI">HI</option>

							<option value="ID">ID</option>

							<option value="IL">IL</option>

							<option value="IN">IN</option>

							<option value="IA">IA</option>

							<option value="KS">KS</option>

							<option value="KY">KY</option>

							<option value="LA">LA</option>

							<option value="ME">ME</option>

							<option value="MD">MD</option>

							<option value="MA">MA</option>

							<option value="MI">MI</option>

							<option value="MN">MN</option>

							<option value="MS">MS</option>

							<option value="MO">MO</option>

							<option value="MT">MT</option>

							<option value="NE">NE</option>

							<option value="NV">NV</option>

							<option value="NH">NH</option>

							<option value="NJ">NJ</option>

							<option value="NM">NM</option>

							<option value="NY">NY</option>

							<option value="NC">NC</option>

							<option value="ND">ND</option>

							<option value="OH">OH</option>

							<option value="OK">OK</option>

							<option value="OR">OR</option>

							<option value="PA">PA</option>

							<option value="RI">RI</option>

							<option value="SC">SC</option>

							<option value="SD">SD</option>

							<option value="TN">TN</option>

							<option value="TX">TX</option>

							<option value="UT">UT</option>

							<option value="VT">VT</option>

							<option value="VA">VA</option>

							<option value="VI">VI</option>

							<option value="WA">WA</option>

							<option value="WV">WV</option>

							<option value="WI">WI</option>

							<option value="WY">WY</option>

						</select>			



				 <script language="JavaScript" type="text/javascript">

				  var cval = "<?php echo $listing_row['STATE']; ?>";

						for(i=0;i<document.forms[1].state.options.length;i++)

							if(document.forms[1].state.options[i].value==cval)

								document.forms[1].state.options[i].selected=true;

					</script>



			</td>

						<td width="53%" align="left"><span class="style1">Zip:</span><BR />

						  <input name="zip" type="text" class="text" id="zip" value = '<?php echo $listing_row['ZIPCODE'] ?>' size=10/></td>

					  </tr>

					</table>



				</TD>

			  <TR>

			  <TR>

			   	<TD colspan="5">Check to see if the property maps: <input onclick="get_mapping()" name="mappit" type="button" value="Map Property" /></TD>

			   </TR>

			</table>

			<div style="padding-top:10px;"><strong>Property Details</strong></div>

			<table width="100%" border="0" cellspacing="0" cellpadding="3">

				<TR>

					<TD colspan="3">

				<table width="100%" border="0" cellspacing="0" cellpadding="0">

					  <tr>

						<td><span class="style1">Property Type:</span><BR />

					  <select name="prop_type" id="prop_type">

					<?php 

					$pquery = "select * from Prop_Types";

					$presult = mysql_query($pquery) or die ("SQL Error".mysql_error());

					while($prop_row=mysql_fetch_assoc($presult))

					{

					



						if($listing_row['PROPTYPE'] === $prop_row['ID'])

						{

						

						?>

						<option value=<?php echo $prop_row['ID']; ?> selected="selected"><?php echo $prop_row['Name']; ?></option>

						<?

						}

						else

						{

						?>

						<option value=<?php echo $prop_row['ID']; ?>><?php echo $prop_row['Name']; ?></option>

						<?

						}

					}

					?>

				</select></td>

						<td><span class="style1">List Date:<BR /></span> 

                  <label>

                  <?php $listdatevals = explode("-",$listing_row['LISTDATE']);?>

                  <select name="listdatemonth" class="text" id="listdatemonth">

                    <option value="01">Jan</option>

                    <option value="02">Feb</option>

                    <option value="03">Mar</option>

                    <option value="04">Apr</option>

                    <option value="05">May</option>

                    <option value="06">Jun</option>

                    <option value="07">Jul</option>

                    <option value="08">Aug</option>

                    <option value="09">Sep</option>

                    <option value="10">Oct</option>

                    <option value="11">Nov</option>

                    <option value="12">Dec</option>

                  </select>

                  <script language="JavaScript" type="text/javascript">

				  var cval = <?php echo $listdatevals[1]; ?>;

						for(i=0;i<document.forms[1].listdatemonth.options.length;i++)

							if(document.forms[1].listdatemonth.options[i].value==cval)

								document.forms[1].listdatemonth.options[i].selected=true;

					</script>

                  -

                  <select name="listdateday" class="text" id="listdateday">

                    <option value="01">1</option>

                    <option value="02">2</option>

                    <option value="03">3</option>

                    <option value="04">4</option>

                    <option value="05">5</option>

                    <option value="06">6</option>

                    <option value="07">7</option>

                    <option value="08">8</option>

                    <option value="09">9</option>

                    <option value="10">10</option>

                    <option value="11">11</option>

                    <option value="12">12</option>

                    <option value="13">13</option>

                    <option value="14">14</option>

                    <option value="15">15</option>

                    <option value="16">16</option>

                    <option value="17">17</option>

                    <option value="18">18</option>

                    <option value="19">19</option>

                    <option value="20">20</option>

                    <option value="21">21</option>

                    <option value="22">22</option>

                    <option value="23">23</option>

                    <option value="24">24</option>

                    <option value="25">25</option>

                    <option value="26">26</option>

                    <option value="27">27</option>

                    <option value="28">28</option>

                    <option value="29">29</option>

                    <option value="30">30</option>

                    <option value="31">31</option>

                  </select>

                  <script language="JavaScript" type="text/javascript">

				  var cval = <?php echo $listdatevals[2]; ?>;

						for(i=0;i<document.forms[1].listdateday.options.length;i++)

							if(document.forms[1].listdateday.options[i].value==cval)

								document.forms[1].listdateday.options[i].selected=true;

					</script>

                  -

                  <select name="listdateyear" class="text" id="listdateyear">

                    <option value="2000">2000</option>

                    <option value="2001">2001</option>

                    <option value="2002">2002</option>

                    <option value="2003">2003</option>

                    <option value="2004">2004</option>

                    <option value="2005">2005</option>

                    <option value="2006" selected="selected">2006</option>



                    <option value="2007">2007</option>

                    <option value="2008">2008</option>

                    <option value="2009">2009</option>

                    <option value="2010">2010</option>

                  </select>

                  <script language="JavaScript" type="text/javascript">

				  var cval = <?php echo $listdatevals[0]; ?>;

						for(i=0;i<document.forms[1].listdateyear.options.length;i++)

							if(document.forms[1].listdateyear.options[i].value==cval)

								document.forms[1].listdateyear.options[i].selected=true;

					</script>

                </label></td>

					  </tr>

					</table>				</TD>

				</TR>

				 <tr>

                <td colspan="3" align="left"></td>

              </tr>

			  <tr>

				<td width="28%"><span class="style1">Price:</span><BR />

				  <input name="price" type="text" class="text" id="price" value="<?php echo $listing_row['LISTPRICE']; ?>" /></td>

	

	<? if(	$listing_row['LISTSTATUS'] == 'SOLD') { ?>		  

				 <td width="28%"><span class="style1">Selling Price:</span><BR />

				  <input name="soldprice" type="text" class="text" id="soldprice" value="<?php echo $listing_row['SALESPRICE']; ?>" /></td>

				  <? } ?>



				<td width="37%"><span class="style1">HOA:</span><BR />

				  <input name="hoa" type="text" class="text" id="price" value="<?php echo $listing_row['ASSOCFEE']; ?>" /></td>

				<td width="35%">&nbsp;</td>

			  </tr>

			  <tr>

				<TD colspan="3">

			  <table width="100%" border="0" cellspacing="0" cellpadding="0">

				  <tr>

					<td>Beds:<BR /><SELECT name="beds" face="arial" size="1">

													<OPTION value="0" > 0 </OPTION>

													<OPTION value="1" > 1 </OPTION>

													<OPTION value="2" > 2 </OPTION>

													<OPTION value="3" > 3 </OPTION>

													<OPTION value="4" > 4 </OPTION>

													<OPTION value="5" > 5 </OPTION>

													<OPTION value="6" > 6 </OPTION>

													<OPTION value="7" > 7 </OPTION>

													<OPTION value="8" > 8 </OPTION>

													<OPTION value="9" > 9 </OPTION>

													<OPTION value="10" > 10 </OPTION>

													

												</SELECT>

												

												<script language="JavaScript" type="text/javascript">

				  var cval = <?php echo $listing_row['BEDS']; ?>;

						for(i=0;i<document.forms[1].beds.options.length;i++)

							if(document.forms[1].beds.options[i].value==cval)

								document.forms[1].beds.options[i].selected=true;

					</script></td>

					<td>Full Baths:<BR /><SELECT name="baths_full" face="arial" size="1">

													<OPTION value="0" > 0 </OPTION>

													<OPTION value="1" > 1 </OPTION>

													<OPTION value="2" > 2 </OPTION>

													<OPTION value="3" > 3 </OPTION>

													<OPTION value="4" > 4 </OPTION>

													<OPTION value="5" > 5 </OPTION>

													<OPTION value="6" > 6 </OPTION>

													<OPTION value="7" > 7 </OPTION>

													<OPTION value="8" > 8 </OPTION>

													<OPTION value="9" > 9 </OPTION>

													<OPTION value="10" > 10 </OPTION>

													

												</SELECT>

												<script language="JavaScript" type="text/javascript">

				  var cval = <?php echo $listing_row['BATHSFULL']; ?>;

						for(i=0;i<document.forms[1].baths_full.options.length;i++)

							if(document.forms[1].baths_full.options[i].value==cval)

								document.forms[1].baths_full.options[i].selected=true;

					</script></td>

					<td>Half Baths:<BR /><SELECT name="baths_half" face="arial" size="1">

													<OPTION value="0" > 0 </OPTION>

													<OPTION value="1" > 1 </OPTION>

													<OPTION value="2" > 2 </OPTION>

													<OPTION value="3" > 3 </OPTION>

													<OPTION value="4" > 4 </OPTION>

													<OPTION value="5" > 5 </OPTION>

													<OPTION value="6" > 6 </OPTION>

													<OPTION value="7" > 7 </OPTION>

													<OPTION value="8" > 8 </OPTION>

													<OPTION value="9" > 9 </OPTION>

													<OPTION value="10" > 10 </OPTION>

													

												</SELECT>

												<script language="JavaScript" type="text/javascript">

				  var cval = <?php echo $listing_row['BATHSHALF']; ?>;

						for(i=0;i<document.forms[1].baths_half.options.length;i++)

							if(document.forms[1].baths_half.options[i].value==cval)

								document.forms[1].baths_half.options[i].selected=true;

					</script>

												</td>

					<td><span class="style3">Total Baths:</span><BR /><SELECT name="baths_total" face="arial" size="1">

													<OPTION value="0" > 0 </OPTION>

													<OPTION value="1" > 1 </OPTION>

													<OPTION value="1.25" > 1.25 </OPTION>

													<OPTION value="1.50" > 1.50 </OPTION>

													<OPTION value="1.75" > 1.75 </OPTION>

													<OPTION value="2" > 2 </OPTION>

													<OPTION value="2.25" > 2.25 </OPTION>

													<OPTION value="2.50" > 2.50 </OPTION>

													<OPTION value="2.75" > 2.75 </OPTION>

													<OPTION value="3" > 3 </OPTION>

													<OPTION value="3.25" > 3.25 </OPTION>

													<OPTION value="3.50" > 3.50 </OPTION>

													<OPTION value="3.75" > 3.75 </OPTION>

													<OPTION value="4" > 4 </OPTION>

													<OPTION value="4.25" > 4.25 </OPTION>

													<OPTION value="4.50" > 4.50 </OPTION>

													<OPTION value="4.75" > 4.75 </OPTION>

													<OPTION value="5" > 5 </OPTION>

													<OPTION value="5.25" > 5.25 </OPTION>

													<OPTION value="5.50" > 5.50 </OPTION>

													<OPTION value="5.75" > 5.75 </OPTION>

													<OPTION value="6" > 6 </OPTION>

													<OPTION value="6.25" > 6.25 </OPTION>

													<OPTION value="6.50" > 6.50 </OPTION>

													<OPTION value="6.75" > 6.75 </OPTION>

													<OPTION value="7" > 7 </OPTION>

													<OPTION value="7.25" > 7.25 </OPTION>

													<OPTION value="7.50" > 7.50 </OPTION>

													<OPTION value="7.75" > 7.75 </OPTION>

													<OPTION value="8" > 8 </OPTION>

													<OPTION value="8.25" > 8.25 </OPTION>

													<OPTION value="8.50" > 8.50 </OPTION>

													<OPTION value="8.75" > 8.75 </OPTION>

													<OPTION value="9" > 9 </OPTION>

													<OPTION value="9.25" > 9.25 </OPTION>

													<OPTION value="9.50" > 9.50 </OPTION>

													<OPTION value="9.75" > 9.75 </OPTION>

													<OPTION value="10" > 10 </OPTION>

													<OPTION value="10.25" > 10.25 </OPTION>

													<OPTION value="10.50" > 10.50 </OPTION>

													<OPTION value="10.75" > 10.75 </OPTION>

													

												</SELECT>

												<script language="JavaScript" type="text/javascript">

				  var cval = <?php echo $listing_row['BATHSTOTAL']; ?>;

						for(i=0;i<document.forms[1].baths_total.options.length;i++)

							if(document.forms[1].baths_total.options[i].value==cval)

								document.forms[1].baths_total.options[i].selected=true;

					</script>

				 </td>

				  </tr>

				</table>



			  </TD>

			  </tr>

			  <tr>

				<td>SQFT:<BR /><input name="sqft" type="text" size=10 class="text" id="sqft" value="<?php echo number_format($listing_row['SQFTTOTAL'], 0, "", ""); ?>" /></td>

				<td>Stories:<BR /><SELECT name="stories" face="arial" size="1">

													<OPTION value="0" > 0 </OPTION>

													<OPTION value="1" > 1 </OPTION>

													<OPTION value="2" > 2 </OPTION>

													<OPTION value="3" > 3 </OPTION>

													<OPTION value="4" > 4 </OPTION>

													<OPTION value="5" > 5 </OPTION>

													<OPTION value="6" > 6 </OPTION>

													<OPTION value="7" > 7 </OPTION>

													<OPTION value="8" > 8 </OPTION>

													<OPTION value="9" > 9 </OPTION>

													<OPTION value="10" > 10 </OPTION>

													

												</SELECT>

												<script language="JavaScript" type="text/javascript">

												  var cval = <?php echo $listing_row['STORIES']; ?>;

												  for(i=0;i<document.forms[1].stories.options.length;i++)

												  if(document.forms[1].stories.options[i].value==cval)

												  document.forms[1].stories.options[i].selected=true;

												</script>

												</td>

				<td>Covered Parking Spaces:<BR />

				  <select name="parking" face="arial" size="1">

                    <option value="0" > 0 </option>

                    <option value="1" > 1 </option>

                    <option value="2" > 2 </option>

                    <option value="3" > 3 </option>

                    <option value="4" > 4 </option>

                    <option value="5" > 5 </option>

                    <option value="6" > 6 </option>

                    <option value="7" > 7 </option>

                    <option value="8" > 8 </option>

                    <option value="9" > 9 </option>

                    <option value="10" > 10 </option>

                    

                  </select>

				  								<script language="JavaScript" type="text/javascript">

												  var cval = <?php echo $listing_row['PARKINGCOVERED']; ?>;

												  for(i=0;i<document.forms[1].parking.options.length;i++)

												  if(document.forms[1].parking.options[i].value==cval)

												  document.forms[1].parking.options[i].selected=true;

												</script>

				  </td>

			  </tr>

			  <tr>

			    <td>Year Built:<BR /><input name="yearbuilt" type="text" size=10 class="text" id="parking" value="<?php echo $listing_row['YEARBUILT']; ?>" /></td>

<!--			    <td>Style:<BR /><input name="style" type="text" class="text" id="style" value="<?php //echo $listing_row['STYLE']; ?>" /></td>

-->				

					<td>Architecture Style:<BR />

				  <select name="style" face="arial" size="1">

				  	<option value="<?php echo $listing_row['STYLE']; ?>" > <?php echo $listing_row['STYLE']; ?>  </option>

                    <option value="Art Deco" > Art Deco </option>

                    <option value="Bungalow" > Bungalow </option>

					<option value="CA Modern" > CA Modern </option>

                    <option value="Cape Cod" > Cape Cod </option>

                    <option value="Colonial" > Colonial </option>

                    <option value="Contemporary" > Contemporary </option>

                    <option value="Craftsman" > Craftsman </option>

                    <option value="Creole" > Creole </option>

                    <option value="Dutch Colonial" > Dutch Colonial </option>

                    <option value="Eichler" > Eichler </option>

					<option value="Federal" > Federal </option>

                    <option value="French Provincial" > French Provincial </option>

                    <option value="Georgian" > Georgian </option>

                    <option value="	Gothic Revival" > Gothic Revival </option>

                    <option value="Greek Revival" > Greek Revival </option>

                    <option value="International" > International </option>

                    <option value="Italiante" > Italiante </option>

					<option value="Mid Century Modern" > Mid Century Modern </option>

                    <option value="Monterey" > Monterey </option>

                    <option value="National" > National </option>

                    <option value="Federal" > Federal </option>

                    <option value="Neoclassical" > Neoclassical </option>

                    <option value="Prairie" > Prairie </option>

                    <option value="Pueblo" > Pueblo </option>

                    <option value="Ranch" > Ranch </option>

					<option value="Regency" > Regency </option>

                    <option value="Saltbox" > Saltbox </option>

                    <option value="Second Empire" > Second Empire </option>

                    <option value="Shed" > Shed </option>

                    <option value="Shingle" > Shingle </option>

                    <option value="Shotgun" > Shotgun </option>

                    <option value="Spanish Eclectic" > Spanish Eclectic </option>

					<option value="Split Level" > Split Level </option>

                    <option value="Stick" > Stick </option>

                    <option value="Tudor" > Tudor </option>

                    <option value="Victorian" > Victorian </option>



			

                 

                  </select></td>



			    <td>MLS Number:<BR />

			      <input name="ml_number" type="text" class="text" id="ml_number" value="<?php echo $listing_row['MLSNUM']; ?>" /></td>

			  </tr>

			  <tr>

			    <td colspan="3">Description:<BR /><textarea name="description" cols="40" rows="5" class="text" id="description" style="width:90%;"><?php echo $listing_row['REMARKS']; ?></textarea></td>

			    </tr>

				<!--

				 <tr>

			    <td colspan="3">Property Website or Landing Page:<BR /><input name="landing_page" type="text" class="text" id="landing_page" style = "width:95%" value="<?php echo $listing_row['LANDING_PAGE']; ?>" /></td>

			    </tr>

				-->

				 <tr>

			    <td colspan="3"><strong>Virtual Tour URL:</strong><BR />

				<?php 

				if($listing_row['VIRTUAL_TOUR_URL']!='')

				{

				?>

				<input name="realivent_vt" type="checkbox" onChange="remove_vt()" id='rvt' value="1"> Use FREE Realivent Virtual Tour<BR />OR<BR>

				<input name="vt" type="text" onChange="use_vt()" class="text" id="vt" style = "width:95%" value="<?php echo $listing_row['VIRTUAL_TOUR_URL']; ?>" />

				<?

				}

				else

				{

				?>

				<input name="realivent_vt" type="checkbox" onChange="remove_vt()" id='rvt' value="1" checked> Use FREE Realivent Virtual Tour<BR />OR<BR>

				<input name="vt" type="text" onChange="use_vt()" class="text" id="vt" style = "width:95%" value="<?php echo $listing_row['VIRTUAL_TOUR_URL']; ?>" /></td>

			   <?

			   }

			   ?>

			    </tr>

				<script language="javascript">

				function use_vt()

				{

					

					if(document.getElementById('vt').value!='')

					document.forms[0].realivent_vt.checked=false;

					//alert(document.forms[0].realivent_vt.value)

				}

				

				function remove_vt()

				{

					

					document.getElementById('vt').value=''



				}

				</script>

				

				 <tr>

			    <td colspan="3">800# (IVR):<BR /><input name="ivr" type="text" class="text" id="ivr" style = "width:95%" value="<?php echo $listing_row['IVR']; ?>" /></td>

			    </tr>

			  <tr>

			    <td colspan="3">

				<div><strong>Additional Information</strong><br />

				<?php 

				

				$sql = "Select * from Users where ID = '".$_SESSION['id']."'";

				$result = mysql_query($sql) or die ("SQL Error".mysql_error());

				$row=mysql_fetch_assoc($result);

				

				?>

				<table width="100%" border="0" cellspacing="0" cellpadding="3">

					<TR>

						<TD colspan="2">

						For Sale By Owner: 

						<?php

						if($listing_row['FSBO'] === 'Yes')

						{

						?>

						<input name="fsbo" type="radio" value="Yes" checked="checked"/> YES  

											<input name="fsbo" type="radio" value="No" /> NO

						<?php 

						}

						else

						{

						?>

						<input name="fsbo" type="radio" value="Yes"/> YES  

											<input name="fsbo" type="radio" value="No"  checked="checked"/> NO

						<?php 

						}

						?>

						</TD>

					</TR>

					

					<TR>

						<TD colspan="2">

						Are you the Listing Agent? 

						<?php

						if($listing_row['LISTING_AGENT'] != -1)

						{

						?>

						<input name="listingagent" type="radio" value="Yes" checked="checked"/> YES  

											<input name="listingagent" type="radio" value="No" /> NO

						<?php 

						}

						else

						{

						?>

						<input name="listingagent" type="radio" value="Yes"/> YES  

											<input name="listingagent" type="radio" value="No"  checked="checked"/> NO

						<?php 

						}

						?>

						</TD>

					</TR>



					<TR>

						<TD colspan="2">

						Display Zillow Comparables on Listing Site(s): 

						<?php

						if($listing_row['display_zillow'] === '1')

						{

						?>

						<input name="zillow_quicklink" type="radio" value="1" checked="checked"/> YES  

											<input name="zillow_quicklink" type="radio" value="0" /> NO

						<?php 

						}

						else

						{

						?>

						<input name="zillow_quicklink" type="radio" value="1"/> YES  

											<input name="zillow_quicklink" type="radio" value="0"  checked="checked"/> NO

						<?php 

						}

						?>

						</TD>

					</TR>



					<!--

					<tr>

					<td>Phone:<BR /><input name="phone" type="text" class="text" id="phone" value="<?php echo $row['Phone']; ?>" /></td>

					<td>Email:<BR /><input name="email" type="text" class="text" id="email" value="<?php echo $row['Email']; ?>"/></td>

				  </tr>

				  <tr>

					<td>Full Name: <BR />

					  <input name="full_name" type="text" class="text" id="full_name" value="<?php echo $row['First_Name']." ".$row['Last_Name']; ?>" /></td>

					<td>Fax Number: <BR />

					  <input name="fax" type="text" class="text" id="fax" value="<?php echo $row['Fax']; ?>"/></td>

				  </tr>

				  <tr>

					<td>Website: <BR />

					  <input name="website" type="text" class="text" id="website" value="<?php echo $row['Website']; ?>" /></td>

					<td>Listing Brokerage:<BR /><input name="listing_company" type="text" class="text" id="listing_company" value="<?php echo $row['Brokerage']; ?>"/></td>

				  </tr>

				  -->

				</table>



				</td>

			    </tr>

				<tr>

			    <td colspan="3">

				<input name="update" type="submit" value="Update Listing" />



				</td>

			    </tr>

			</table>



			<?php 

			

			}

			

			?>

	

			

			</td>

			<td width=200 align="left" valign="top" style="padding-left:10px; border-left:1px solid #CCCCCC;">

			<div style="font-size:16px; color:#FF9900">Features:</div>

			<div style="font-size:14px; color:#333333; font-weight:bold">Kitchen</div>

			<input name="kitchen_features[]" type="checkbox" id="kitchen_features" value="Breakfast nook">

                            Breakfast nook<Br>

			<input name="kitchen_features[]" type="checkbox" id="kitchen_features" value="Dishwasher">

                            Dishwasher<Br>

			<input name="kitchen_features[]" type="checkbox" id="kitchen_features" value="Refrigerator">

                            Refrigerator<Br>

			<input name="kitchen_features[]" type="checkbox" id="kitchen_features" value="Stove / Oven">

                            Stove/Oven<Br>

			<input name="kitchen_features[]" type="checkbox" id="kitchen_features" value="Microwave">

                            Microwave<Br>

			<input name="kitchen_features[]" type="checkbox" id="kitchen_features" value="Granite countertop">

                            Granite countertop<Br>

			<input name="kitchen_features[]" type="checkbox" id="kitchen_features" value="Stainless steel appliances">

                            Stainless steel appliances<Br>

							

			

			

			<div style="font-size:14px; color:#333333; font-weight:bold">Interior</div>

            <input name="interior_features[]" type="checkbox" id="interior_features" value="Central A/C">

                            Central A/C<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Central heat">

                            Central heat<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Fireplace">

                            Fireplace<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="High / Vaulted ceiling">

                            High/Vaulted ceiling<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Walk-in closet">

                            Walk-in closet<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Hardwood floor">

                            Hardwood floor<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Tile flooring">

                            Tile flooring<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Wall to wall carpeting">

                            Wall to wall carpeting<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Family room">

                            Family room<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Living room">

                            Living room<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Bonus/Rec room">

                            Bonus/Rec room<Br>

            <input name="interior_features[]" type="checkbox" id="interior_features" value="Office / Den">

                            Office/Den<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Dining room">

                            Dining room<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Attic">

                            Attic<Br>

            <input name="interior_features[]" type="checkbox" id="interior_features" value="Basement">

                            Basement<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Washer">

                            Washer<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Dryer">

                            Dryer<Br>

			<input name="interior_features[]" type="checkbox" id="interior_features" value="Laundry area">

                            Laundry area<Br>

							

							



			<div style="font-size:14px; color:#333333; font-weight:bold">Exterior</div>

			

			<input name="exterior_features[]" type="checkbox" id="exterior_features" value="Balcony, Deck, or Patio">

                            Balcony, Deck, or Patio<Br>

			<input name="exterior_features[]" type="checkbox" id="exterior_features" value="Yard">

                            Yard<Br>

			<input name="exterior_features[]" type="checkbox" id="exterior_features" value="Swimming pool">

                            Swimming pool<Br>

			<input name="exterior_features[]" type="checkbox" id="exterior_features" value="Jacuzzi / Whirlpool">

                            Jacuzzi/Whirlpool<Br>

			<input name="exterior_features[]" type="checkbox" id="exterior_features" value="Sauna">

                            Sauna<Br>

			</form>

			<?php 

			$sql = "Select * from Prop_Features where Listing_ID = '".$ListingID."'";

			$result = mysql_query($sql) or die ("SQL Error".mysql_error());

			while($row=mysql_fetch_assoc($result))

			{

			?>

				 <script language="JavaScript" type="text/javascript">

				 var formblock = document.getElementsByTagName('input')

				 //alert(formblock.length)

				 var cval = '<?php echo $row['Feature']; ?>';

				  

						for(i=0;i<formblock.length;i++)

						

							if(formblock[i].value==cval)

								formblock[i].checked = true

						

								//document.getElementById('kitchen_features').checked = true;

					</script>

			<?

			}

			?>

							

			<!--<a href=amenities.php>More, including HOA Amenities</a>-->



			</td>

		  </tr>

		</table>



		

			



	</td>

  </tr>

 

</table>



		

	</td>

  </tr>

</table>

<?php include('../footer.php'); ?>

</body>

</html>

<?php require("../db/closedb.php");?>